(HSP3) sample9 [ファイル読み込み版 バーコード・QRコード読み取り]_x64.hsp

sample\hspdsc\64bit\(HSP3) sample9 [ファイル読み込み版 バーコード・QRコード読み取り]_x64.hsp » Plain Format

#include "hsp3_64.as"
#include "hspbar64.as"

	title "ファイルからバーコード読み取りサンプル"

	dialog "jpg;*.gif;*.bmp",16
	if stat == 0 : end
	
	buffer 2
	picload refstr
	mref vram, 66						// BGR... の順番で積まれている
	x = ginfo_winx						// 幅
	y = ginfo_winy						// 高さ
	stride = -(x * 24 + 31) / 32 * 4	// Stride (24bit RGB)
	gsel 0, 1
	
	// 初期化
	bar_Init 1, 1, BarcodeFormat_Default	// JANコードとQRコードに対応
	nIndex = stat
	
	// 結果格納用変数
	size = bar_GetSize()
	sdim res, size
	
	// 読み込み
	bar_Read nIndex, ImageFormat_BGR, vram, x, y, stride, res		// VRAM は BGR 順
	if ( stat < 0 ) {
		dialog "読み込みエラー"
		bar_UnInit nIndex
		end
	} else : if ( stat == 0 ) {
		dialog "画像内にバーコードが見つかりませんでした。"
		bar_UnInit nIndex
		end
	}
	
	// テキスト取得
	bar_CopyTextU8_GetSize res, 0
	txtsize = stat
	
	sdim txt, txtsize
	bar_CopyTextU8 res, txt, txtsize
	
	mes txt
	
	// 解放
	bar_Free res
	bar_UnInit nIndex